package com.gqz.patrol.app.service.impl;

import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.gqz.common.core.domain.R;
import com.gqz.patrol.app.entity.EnWzJfEquipEntity;
import com.gqz.patrol.app.entity.EnWzJfglEntity;
import com.gqz.patrol.app.mapper.EnWzJfglMapper;
import com.gqz.patrol.app.service.IJfGlService;
import com.gqz.patrol.vo.PatrolJfInfoVo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: app-使用-机房管理
 */
@Service("appJfGlService")
public class JfGlServiceImpl implements IJfGlService {

    @Resource
    private EnWzJfglMapper jfglMapper;

    /**
     * @description: 查询所需机房
     */
    @Override
    public R<Object> queryNeededJfList() {
        return null;
    }

    /**
     * @description: 查询机房设备信息
     */
    @Override
    public R<Object> queryEquipListByJf(List<String> jfIds) {
        return null;
    }

    /**
     * @description: 查询机房+机房设备信息
     */
    @Override
    public List<PatrolJfInfoVo> queryJfEquipList() {
        MPJLambdaWrapper<EnWzJfglEntity> queryWrapper = new MPJLambdaWrapper<>();

        queryWrapper.selectAs(EnWzJfglEntity::getId, PatrolJfInfoVo::getJfNo)
                .select(EnWzJfglEntity::getJfName)
                .selectCollection(EnWzJfEquipEntity.class, PatrolJfInfoVo::getEquipInfoList)
                .leftJoin(EnWzJfEquipEntity.class, EnWzJfEquipEntity::getSsjfbm, EnWzJfglEntity::getId);

        return jfglMapper.selectJoinList(PatrolJfInfoVo.class, queryWrapper);
    }
}
